#!/bin/bash

# pine
# File ID: 7420db28-5d42-11df-9a7c-90e6ba3022ac
# Locking for pine

echo "Nei. Bruk mutt."
exit

lockdir=$HOME/.lock
[ "$1" = "-f" ] && { shift; rm -rf $lockdir; }
[ -d $lockdir/. ] || mkdir $lockdir || { echo "$lockdir: Klarte ikke mkdir" >&2; exit 1; }
lockname=$lockdir/pine
until mkdir $lockname 2>/dev/null; do
	echo "$0: $lockname: Venter på at \"`cat $lockname/info`\" skal slippe locken..." >&2
	sleep 2
done
echo "$(tty) $(date +"%Y-%m-%d %H:%M:%S")" >$lockname/info

unset LC_CTYPE

if [ -x /usr/local/bin/pine ]; then
	/usr/local/bin/pine $*
elif [ -x /usr/bin/pine ]; then
	/usr/bin/pine $*
fi

rm $lockname/info
rmdir $lockname
